<?php
function t($text) {
	return nl2br ( str_replace ( ' ', '&nbsp;', htmlspecialchars ( $text ) ) );
}
function t2js($content) {
	return str_replace ( array ("\r", "\n" ), array ('', '\n' ), addslashes ( $content ) );
}
function __error_dump_trace($ex) {
	echo '<strong>Exception: </strong>' . get_class ( $ex ) . "<br />\n";
	if ($ex->getMessage () != '') {
		echo '<strong>Message: </strong>' . $ex->getMessage () . "<br />\n";
	}
	echo "<br />\n";
	
	$trace = $ex->getTrace ();
	$ix = count ( $trace );
	foreach ( $trace as $point ) {
		$file = isset ( $point ['file'] ) ? $point ['file'] : null;
		$line = isset ( $point ['line'] ) ? $point ['line'] : null;
		$id = md5 ( "{$file}({$line})" );
		$function = isset ( $point ['class'] ) ? "{$point['class']}::{$point['function']}" : $point ['function'];
		
		$args = array ();
		if (is_array ( $point ['args'] ) && count ( $point ['args'] ) > 0) {
			foreach ( $point ['args'] as $arg ) {
				switch (gettype ( $arg )) {
					case 'array' :
						$args [] = 'array(' . count ( $arg ) . ')';
						break;
					case 'resource' :
						$args [] = gettype ( $arg );
						break;
					case 'object' :
						$args [] = get_class ( $arg );
						break;
					case 'string' :
						if (strlen ( $arg ) > 30) {
							$arg = substr ( $arg, 0, 27 ) . ' ...';
						}
						$args [] = "'{$arg}'";
						break;
					default :
						$args [] = $arg;
				}
			}
		}
		$args = implode ( ", ", $args );
		
		echo "<hr /><strong>Filename:</strong> <a href=\"javascript:switch_filedesc('{$id}');\">{$file} [{$line}]</a><br />#{$ix} {$function}($args)<div id=\"{$id}\" class=\"filedesc\" style=\"display: none;\">ARGS:";
		
		dump ( $point ['args'] );
		echo "SOURCE CODE: <br />\n";
		echo __error_show_source ( $file, $line );
		echo "\n</div>\n";
		echo "<br />\n";
		$ix --;
	}
}
function __error_show_source($file, $line, $prev = 10, $next = 10) {
	if (! (file_exists ( $file ) && is_file ( $file ))) {
		return '';
	}
	
	$data = file ( $file );
	$count = count ( $data ) - 1;
	
	//count which lines to display
	$start = $line - $prev;
	if ($start < 1) {
		$start = 1;
	}
	$end = $line + $next;
	if ($end > $count) {
		$end = $count + 1;
	}
	
	//displaying
	$out = '<table cellspacing="0" cellpadding="0">';
	
	for($x = $start; $x <= $end; $x ++) {
		$out .= "  <tr>\n";
		if ($line != $x) {
			$out .= "    <td class=\"line-num\">";
		} else {
			$out .= "    <td class=\"line-num-break\">";
		}
		$out .= str_repeat ( '&nbsp;', (strlen ( $end ) - strlen ( $x )) + 1 );
		$out .= $x;
		$out .= "&nbsp;</td>\n";
		
		$out .= "    <td class=\"source\">&nbsp;";
		$out .= t ( $data [$x - 1] );
		$out .= "</td>\n  </tr>\n";
	}
	$out .= "</table>\n";
	return $out;
}
function __error_filelink($filename) {
	$path = realpath ( $filename );
	if ($path) {
		echo $path;
	} else {
		echo $filename;
	}
}
function __error_highlight_string($code) {
	$text = t2js ( $code );
	$code = str_replace ( "<br />", "\n", highlight_string ( $code, true ) );
	
	echo "<pre>[<a href=\"#\" onclick=\"copytextToClipboard('{$text}'); return false;\">Copy To Clipboard</a>]{$code}</pre>";
}
?>
<?php

$config = Zend_Registry::get ( 'config' );
if ($config->general->show_error) {
	if (substr ( $e->getMessage (), 0, 28 ) == "Invalid controller specified" || (substr ( $e->getMessage (), 0, 6 ) == "Action" && substr ( $e->getMessage (), - 46 ) == "does not exist and was not trapped in __call()")) {
		header ( "HTTP/1.x 404 Not Found" );
		print_r ( "您访问的页面不存在<br />" );
		print_r ( "The page you are trying to access does not exist or perhaps it was removed." );
	} else {
		header ( "HTTP/1.x 500 Internal Server Error" );
		print_r ( "遇到了一些内部错误<br />" );
		print_r ( "has encountered some internal error. The application administrators have been informed and this error will be fixed soon" );
	}
}
?>
<meta http-equiv="Content-Type" content="text/html" charset="utf-8" />
<style>
/* CSS Document */
body {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 12px;
}

h1 {
	font-size: 20px;
	font-weight: bold;
	color: #6699cc;
}

h2 {
	font-size: 14px;
	font-weight: bold;
	margin: 0px;
	padding: 0px;
	margin-bottom: 8px;
}

;
code,pre {
	color: #4444AA;
	font-size: 12px;
}

pre {
	margin-left: 12px;
	border-left: 1px solid #CCCCCC;
	padding-left: 20px;
}

a {
	color: #3366CC;
	text-decoration: none;
}

a:hover {
	text-decoration: underline;
}

.tip {
	background: #eeffee;
	padding: 10px;
	border: 1px solid #ccddcc;
}

.tip h2 {
	color: #006600;
}

.error {
	background: #ffeeee;
	padding: 5px;
	border: 1px solid #ddcccc;
}

.error h2 {
	color: #FF3300;
}

.track {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 12px;
	background-color: #FFFFCC;
	padding: 10px;
	border: 1px solid #FF9900;
}

.filedesc {
	margin-left: 16px;
	color: #666666;
}

.line-num {
	font-size: 12px;
	vertical-align: top;
}

.line-num-break {
	font-size: 12px;
	font-weight: bold;
	color: white;
	background-color: red;
	vertical-align: top;
}

.source {
	font-size: 12px;
	vertical-align: top;
}
</style>
<script language="javascript" type="text/javascript">
function switch_filedesc(id)
{
    var el = document.getElementById(id);
    if (el.style.display == 'none') {
        el.style.display = 'block';
    } else {
        el.style.display = 'none';
    }
}

function copytextToClipboard(txt)
{
    if (window.clipboardData) {
        window.clipboardData.clearData();
        window.clipboardData.setData('Text', txt);
    }
}

</script>
<h1><?php echo $e->getMessage(); ?></h1>

<div class="error">
	<h2>Error reason:</h2>
	Uncaptured exception.
</div>


<p>
	<strong>Details:</strong>
<?php echo t($e->__toString()); ?>
</p>



<div class="track">
<?php __error_dump_trace($e); ?>
</div>
<?php
exit ();
?>